package teaching.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import teaching.pojo.Course;
import teaching.pojo.CourseStudent;

import java.util.List;

/**
 * Author:20201002983_郑雨蓓
 * Date: 2024/3/6
 * Description:
 */
public interface CourseMapper {

    int addCourse(@Param("course") Course course);

    int updateCourse(@Param("course") Course course);

    @Select("select * from course where userid = #{userid} ")
    List<Course> list(@Param("userid") Long userid);

    @Delete("delete from course where cid = #{cid}")
    int deleteCourse(Long cid);

    @Update("ALTER TABLE `course` AUTO_INCREMENT = 1")
    void resetAutoIncrement();

    @Select("select course.* from course_student,course " +
            "where course_student.student_id=#{sid} and course.cid=course_student.cid")
    List<Course> listStudentCourse(@Param("sid") Long sid);

    void addMulCourseStudent(long cid, List<Long> studentIds);
}
